package com.api.acceptance.group;

import java.util.List;

import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.api.test.VoidContextLoader;
import com.api.util.repo.impl.DomainUser;
import com.zyncro.api.IGroupApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.GroupApi;
import com.zyncro.api.model.GroupApiType;
import com.zyncro.api.model.GroupFilterApiType;
import com.zyncro.api.model.GroupOrderFieldFilterApiType;
import com.zyncro.api.model.OrderFilterApiType;
import com.zyncro.api.model.PagedItemsResultApi;

@ContextConfiguration(loader = VoidContextLoader.class)
public class GetGroupsAcceptance extends AbstractApiTest {

	@BeforeClass
	protected void setUp() throws Exception {

		DomainUser mainAdmin = getRepo().getMainUser("GetGroups");

		getApi().login(mainAdmin.getAppId(), mainAdmin.getPassword());
	}

	@Test
	public void testGetAllGroups() throws ZyncroApiException {

		int pageNumber = 0;
		int itemsPerPage = 0;
		List<GroupApiType> groupTypes = null;
		GroupFilterApiType groupFilter = null;
		String startsWith = "";

		OrderFilterApiType orderFilter = null;
		GroupOrderFieldFilterApiType orderFilterField = null;

		PagedItemsResultApi<GroupApi> result = getApi().getService(IGroupApiService.class).getGroups(pageNumber, itemsPerPage, groupTypes,
				groupFilter, startsWith, orderFilterField, orderFilter);

		Assert.assertEquals(result.getTotalItems(), 2);
	}
}
